bitkeeper revision 1.1136 (410fcd1dXCUIdIRu9TcJZuNDJEcV9w)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Tue, 3 Aug 2004 17:36:29 +0000 (17:36 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Tue, 3 Aug 2004 17:36:29 +0000 (17:36 +0000)
Merge coherent alloc routines in 2.4/2.6.

.rootkeys
linux-2.4.26-xen-sparse/arch/xen/kernel/pci-dma.c [deleted file]
linux-2.4.26-xen-sparse/mkbuildtree
linux-2.6.7-xen-sparse/arch/xen/i386/kernel/pci-dma.c

index 5b737a666f750f2345900b25f7b952cc837c13d6..537c1cba0129dcc1c92e5339dfd6c1d1f9f72a3c 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
@@ -70,7 +70,6 @@
 3e5a4e65RMGcuA-HCn3-wNx3fFQwdg linux-2.4.26-xen-sparse/arch/xen/kernel/i386_ksyms.c
 3e5a4e653U6cELGv528IxOLHvCq8iA linux-2.4.26-xen-sparse/arch/xen/kernel/irq.c
 3e5a4e65muT6SU3ck47IP87Q7Ti5hA linux-2.4.26-xen-sparse/arch/xen/kernel/ldt.c
-4051db84bZeRX7a_Kh6VyyDuT5FOIg linux-2.4.26-xen-sparse/arch/xen/kernel/pci-dma.c
 4051db95N9N99FjsRwi49YKUNHWI8A linux-2.4.26-xen-sparse/arch/xen/kernel/pci-pc.c
 3e5a4e65IGt3WwQDNiL4h-gYWgNTWQ linux-2.4.26-xen-sparse/arch/xen/kernel/process.c
 3e5a4e66tR-qJMLj3MppcKqmvuI2XQ linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c
diff --git a/linux-2.4.26-xen-sparse/arch/xen/kernel/pci-dma.c b/linux-2.4.26-xen-sparse/arch/xen/kernel/pci-dma.c
deleted file mode 100644 (file)
index e841ba8..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Dynamic DMA mapping support.
- *
- * On i386 there is no hardware dynamic DMA address translation,
- * so consistent alloc/free are merely page allocation/freeing.
- * The rest of the dynamic DMA mapping interface is implemented
- * in asm/pci.h.
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-                          dma_addr_t *dma_handle)
-{
-       void *ret;
-       int gfp = GFP_ATOMIC;
-       unsigned int order = get_order(size);
-       unsigned long vstart;
-
-       if (hwdev == NULL || ((u32)hwdev->dma_mask < 0xffffffff))
-               gfp |= GFP_DMA;
-
-       ret = (void *)vstart = __get_free_pages(gfp, order);
-       if (ret == NULL)
-               return ret;
-
-       /*
-        * Ensure multi-page extents are contiguous in machine memory.
-        * This code could be cleaned up some, and the number of
-        * hypercalls reduced.
-        */
-       if (size > PAGE_SIZE) {
-               pgd_t         *pgd; 
-               pmd_t         *pmd;
-               pte_t         *pte;
-               unsigned long  pfn, i;
-               /* 1. Zap current PTEs, giving away the underlying pages. */
-               for (i = 0; i < (1<<order); i++) {
-                       pgd = pgd_offset_k(   (vstart + (i*PAGE_SIZE)));
-                       pmd = pmd_offset(pgd, (vstart + (i*PAGE_SIZE)));
-                       pte = pte_offset(pmd, (vstart + (i*PAGE_SIZE)));
-                       pfn = pte->pte_low >> PAGE_SHIFT;
-                       queue_l1_entry_update(pte, 0);
-                       flush_page_update_queue();
-                       if (HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 
-                               &pfn, 1, 0) != 1) BUG();
-               }
-               /* 2. Get a new contiguous memory extent. */
-               if (HYPERVISOR_dom_mem_op(MEMOP_increase_reservation,
-                       &pfn, 1, order) != 1) BUG();
-               /* 3. Map the new extent in place of old pages. */
-               for (i = 0; i < (1<<order); i++) {
-                       pgd = pgd_offset_k(   (vstart + (i*PAGE_SIZE)));
-                       pmd = pmd_offset(pgd, (vstart + (i*PAGE_SIZE)));
-                       pte = pte_offset(pmd, (vstart + (i*PAGE_SIZE)));
-                       queue_l1_entry_update(pte, 
-                               ((pfn+i)<<PAGE_SHIFT)|__PAGE_KERNEL);
-                       queue_machphys_update(pfn+i,
-                               (__pa(ret)>>PAGE_SHIFT)+i);
-                       phys_to_machine_mapping[(__pa(ret)>>PAGE_SHIFT)+i] =
-                               pfn+i;
-                        flush_page_update_queue();
-               }
-               flush_page_update_queue();
-       }
-
-       memset(ret, 0, size);
-       *dma_handle = virt_to_bus(ret);
-
-       return ret;
-}
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
-                        void *vaddr, dma_addr_t dma_handle)
-{
-       free_pages((unsigned long)vaddr, get_order(size));
-}
index cb87a6d4ff7365dd37d93405af0e741df2f4a2cb..8230005e307ba0c0eca25280f0aef7e46b14344b 100755 (executable)
@@ -221,6 +221,7 @@ ln -sf ../../i386/kernel/sys_i386.c
 ln -sf ../../../${LINUX_26}/arch/xen/kernel/ctrl_if.c
 ln -sf ../../../${LINUX_26}/arch/xen/kernel/evtchn.c
 ln -sf ../../../${LINUX_26}/arch/xen/i386/kernel/ioport.c
+ln -sf ../../../${LINUX_26}/arch/xen/i386/kernel/pci-dma.c
 
 cd ${AD}/arch/xen/lib
 ln -sf ../../i386/lib/checksum.S 
index 6b604383e8a5591146d9749b8ca89942d6b36148..6f5e1b2c7379c118f881b4d059482bc1e1530b62 100644 (file)
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/pci.h>
+#include <linux/version.h>
 #include <asm/io.h>
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#define pte_offset_kernel pte_offset
+void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
+                          dma_addr_t *dma_handle)
+#else
 void *dma_alloc_coherent(struct device *dev, size_t size,
                           dma_addr_t *dma_handle, int gfp)
+#endif
 {
        void *ret;
        unsigned int order = get_order(size);
        unsigned long vstart;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+       int gfp = GFP_ATOMIC;
+
+       if (hwdev == NULL || ((u32)hwdev->dma_mask < 0xffffffff))
+               gfp |= GFP_DMA;
+#else
        /* ignore region specifiers */
        gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
 
        if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
                gfp |= GFP_DMA;
+#endif
 
        ret = (void *)vstart = __get_free_pages(gfp, order);
        if (ret == NULL)
@@ -76,8 +90,13 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
        return ret;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+void pci_free_consistent(struct pci_dev *hwdev, size_t size,
+                        void *vaddr, dma_addr_t dma_handle)
+#else
 void dma_free_coherent(struct device *dev, size_t size,
                         void *vaddr, dma_addr_t dma_handle)
+#endif
 {
        free_pages((unsigned long)vaddr, get_order(size));
 }